<?php $singleid = get_the_ID();?>
<div class="grid_19 block">
        <div class="page_detail" id="page-<?php the_ID();?>">
            <h1 class="title"><?php the_title();?></h1>
            <div class="">
            	<label>Tin đăng: <?php the_date('d/m/Y');?></label>
            	<label>&nbsp;|&nbsp;Lượt xem: 
            	
            	<?php 
            	$showpostview = get_post_meta(get_the_ID(),$wpdb->prefix.'showpostview',true);
            	$tshowpostview = intval($showpostview);
            	$showpostviewnew  = $tshowpostview+1;
            	update_post_meta(get_the_ID(), $wpdb->prefix.'showpostview',$showpostviewnew);
            	
            	echo $showpostview.' Lượt.';
            	?>
            	
            	</label>
            	<?php include TEMPLATEPATH.'/templates/tpl-share-button.php';?>
            </div>
            <div class="content_detail">
            	<?php the_content();?> 
            	
            	<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Trang:', THEMENAME ), 'after' => '</div>' ) ); ?>
            	
            	<!-- .entry-content -->
				<div class="entry-meta">
					<?php edit_post_link( __( 'Sửa', THEMENAME ), '<span class="edit-link">', '</span>' ); ?>
				</div>
				<!-- .entry-meta -->
				
				
				<?php 
				// bai viet khac
				//$singleid = get_the_ID();
				if($post->post_type=='post')
				{
					$obj_term = wp_get_object_terms($singleid, 'category');
					$_taxonomy = 'category';		
					$tax_query = array(
								'relation' => 'AND',
								array(
										'taxonomy' => $_taxonomy,
										'field' => 'id',
										'terms' => array($obj_term[0]->term_id)
								)
						);			
				}	
				else 
				{	
					if($post->post_type=='dich-vu')
					{
						$_taxonomy = 'dich-vu-bds';
						$obj_term = wp_get_object_terms($singleid, $_taxonomy);
						
						if($obj_term[0]->term_id){
							$tax_query = array(
									'relation' => 'AND',
									array(
											'taxonomy' => $_taxonomy,
											'field' => 'id',
											'terms' => array($obj_term[0]->term_id)
									)
							);
						}
					}	
					else if($post->post_type=='tin-tuc')
					{
						$_taxonomy = 'tin-tuc-bds';
						$obj_term = wp_get_object_terms($singleid, $_taxonomy);
						
						if($obj_term[0]->term_id){
							$tax_query = array(
									'relation' => 'AND',
									array(
											'taxonomy' => $_taxonomy,
											'field' => 'id',
											'terms' => array($obj_term[0]->term_id)
									)
							);
						}
					}
					else if($post->post_type=='tu-van')
					{
						$_taxonomy = 'tu-van-bds';
						$obj_term = wp_get_object_terms($singleid, $_taxonomy);
						
						if($obj_term[0]->term_id){
							$tax_query = array(
									'relation' => 'AND',
									array(
											'taxonomy' => $_taxonomy,
											'field' => 'id',
											'terms' => array($obj_term[0]->term_id)
									)
							);
						}
					}	
					else
					{
					
					}
				}
				
				if($tax_query)
				{
					$args = array(
							'post_type' 		=> $post->post_type,
							'post__not_in' 		=> array($singleid),
							'showposts'			=> get_option("posts_per_page"),
							'orderby'			=>'modified','order'=>'DESC',
							'tax_query' 		=> $tax_query
								
					);
				}	
				else
				{
					$args = array(
							'post_type' 		=> $post->post_type,
							'post__not_in' 		=> array($singleid),
							'showposts'			=> get_option("posts_per_page"),
							'orderby'			=>'modified','order'=>'DESC'								
					);
				}	
				
				//print_r($args);
				
				$otherpost = new WP_Query($args);
				if($otherpost->have_posts())
				{	
				?>
				<div class="related_post">
					<h3 class="underline">Các tin khác</h3>
						<ul>
							<?php 
							while ($otherpost->have_posts())
							{
								$otherpost->the_post();
								?>
								<li>
									<a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?></a><span> [<?php echo get_the_date('d/m/Y');?>]</span>
								</li>
								<?php 
							}	
							?>
						</ul>
					</div>
				<?php 
				}
				unset($otherpost);
				?>	
				
            </div>
            
            <!-- Display comment -->            
            <?php
			//print_r($post);
            
            if($myoptions['post_comment_display'] && $myoptions['post_comment_display']=='display')
			{				
				$post_id = get_the_ID();
				?>
	            <div class="product-detail-comment-onlocal">
					<!-- **Comment Entries** -->   	
		            <div id="comments" class="comment-entry">
		                <?php  comments_template('', true); ?>
		            </div><!-- **Comment Entries - End** -->
				</div>
	            <?php 
			}
            ?>
            <!-- End Display comment -->
            
        </div>
    </div>